package com.coai.common.dto

import java.time.Instant

/**
 * 基础响应对象
 */
data class ApiResponse<T>(
    val success: Boolean,
    val data: T? = null,
    val message: String? = null,
    val code: String? = null,
    val timestamp: Instant = Instant.now()
) {
    companion object {
        fun <T> success(data: T): ApiResponse<T> {
            return ApiResponse(success = true, data = data)
        }
        
        fun <T> success(data: T, message: String): ApiResponse<T> {
            return ApiResponse(success = true, data = data, message = message)
        }
        
        fun <T> error(message: String, code: String? = null): ApiResponse<T> {
            return ApiResponse(success = false, message = message, code = code)
        }
    }
}

/**
 * 分页请求
 */
data class PageRequest(
    val page: Int = 0,
    val size: Int = 20,
    val sort: String? = null,
    val order: SortOrder = SortOrder.DESC
)

enum class SortOrder {
    ASC, DESC
}

/**
 * 分页响应
 */
data class PageResponse<T>(
    val content: List<T>,
    val page: Int,
    val size: Int,
    val totalElements: Long,
    val totalPages: Int,
    val hasNext: Boolean,
    val hasPrevious: Boolean
)
